$(function () {
  $("#ce").stop().animate({ top: "0", right: "0" }, 500);
  $("#xin6")
    .children()
    .eq(0)
    .mouseover(function () {
      $("#damao").show().siblings().hide();
    });
  $("#xin6")
    .children()
    .eq(0)
    .mouseout(function () {
      $("#damao").show().siblings().hide();
    });
  $("#xin6")
    .children()
    .eq(1)
    .mouseover(function () {
      $("#zuo1").show().siblings().hide();
    });
  $("#xin6")
    .children()
    .eq(1)
    .mouseout(function () {
      $("#zuo1").hide().siblings("#damao").show();
    });
  $("#zuo1").mouseover(function () {
    $(this).show().siblings("#damao").hide();
  });
  $("#zuo1").mouseout(function () {
    $(this).hide().siblings("#damao").show();
  });
  $("#you")
    .children()
    .mouseover(function () {
      $(this)
        .stop()
        .animate({ left: "-10px" }, 500)
        .siblings()
        .stop()
        .animate({ left: 0 });
    });
  $("#you")
    .children()
    .mouseout(function () {
      $(this).stop().animate({ left: "0" }, 500);
    });

  $("#zuo1 li").mouseover(function () {
    $("#zuo2").show().siblings("#zuo1").show().siblings("#damao").hide();
  });
  $("#zuo1 li").mouseout(function () {
    $("#zuo2").show().siblings("#zuo1").show().siblings("#damao").hide();
  });
  $("#zuo2").mouseover(function () {
    $("#zuo2").show().siblings("#zuo1").show().siblings("#damao").hide();
  });
  $("#zuo2").mouseout(function () {
    $("#zuo2").hide().siblings("#zuo1").show().siblings("#damao").hide();
  });
  $("#guan").mouseover(function () {
    $("#zhu19").css({ display: "block" });
    $("#zhu7").css({ display: "none" });
    $("#zhu14").css({ display: "none" });
  });
  $("#re").mouseover(function () {
    $("#zhu19").css({ display: "none" });
    $("#zhu7").css({ display: "block" });
    $("#zhu14").css({ display: "block" });
  });
  $.ajax({
    url: "http://jx.xuzhixiang.top/ap/api/allproductlist.php",
    type: "get",
    data: { pagesize: 8, pagenum: 0, uid: 74599 },
    success: function (data) {
      let skr = data.data;
      let str = "";
      skr.forEach((item) => {
        str += `<li  data-id="${item.pid}">
                <img src="${item.pimg}" >
                <p>${item.pname}</p>
                <p>￥${item.pprice}</p>
                </li>`;
      });
      $("#zhu19 ul").html(str);
      $("#zhu19 ul li").click(function () {
        let hezi = $(this).attr("data-id");
        localStorage.setItem("data-id", hezi);
        window.location.href = "./xiangqing.html";
      });
    },
  });
  $("#ce18").click(function () {
    scrollTo(0, 0);
  });
  $("#zhu11 img").mouseover(function () {
    $(this).stop().animate({ top: "-10px" }, 500);
  });
  $("#zhu11 img").mouseout(function () {
    $(this).stop().animate({ top: 0 }, 500);
  });
  $("#zhu12 img").mouseover(function () {
    $(this).stop().animate({ top: "-10px" }, 500);
  });
  $("#zhu12 img").mouseout(function () {
    $(this).stop().animate({ top: 0 }, 500);
  });
  $("#zhu13 img").mouseover(function () {
    $(this).stop().animate({ top: "-10px" }, 500);
  });
  $("#zhu13 img").mouseout(function () {
    $(this).stop().animate({ top: 0 }, 500);
  });
  // $("h2").click(function () {
  //     $(this).css({ "color": "red" }).siblings().css({ "color": "black" })
  // })
  $(".zhudeng1").click(function () {
    $(".zhubox2").show();
    console.log($(".zhubox2"));
    $("#zhubox").hide();
    $(".zhubox3").hide();
  });
  $(".zhudeng2").click(function () {
    $(".zhubox3").show();
    $(".zhubox2").hide();
    $("#zhubox").hide();
  });
  $(".zhudeng3").click(function () {
    $(".zhubox3").show();
    $(".zhubox2").hide();
    $("#zhubox").hide();
  });
  $(".ji3").click(function () {
    $(".zhubox2").show();
  });
  $("#zhubox").hide();
  $(".zhubox2").hide();
  $(".zhubox3").hide();
  // $(".zhu").click(function () {
  //     window.location.href="shouye.html"
  // })
  // $(".zhu3").click(function () {
  //     window.location.href="shouye.html"
  // })
  $("#zhuzhu11").click(function () {
    $.ajax({
      url: "http://jx.xuzhixiang.top/ap/api/reg.php",
      type: "get",
      data: { username: $("#zhushou").val(), password: $("#zhuduan").val() },
      success: function (data) {
        if (data.code) {
          $.ajax({
            url: "http://jx.xuzhixiang.top/ap/api/login.php",
            type: "get",
            data: {
              username: $("#zhushou").val(),
              password: $("#zhuduan").val(),
            },
            success: function (data) {
              if (data.code) {
                window.location.href = "./index.html";
              } else {
                alert("登陆失败");
              }
            },
          });
        } else {
          alert("注册失败");
        }
      },
    });
  });
  $(".zhuzhu21").click(function () {
    $.ajax({
      url: "http://jx.xuzhixiang.top/ap/api/login.php",
      type: "get",
      data: { username: $(".zhushou").val(), password: $(".zhuduan").val() },
      success: function (data) {
        if (data.code) {
          window.location.href = "./index.html";
          localStorage.setItem("username", $(".zhushou").val());
          localStorage.setItem("password", $(".zhuduan").val());
          localStorage.setItem("uid", data.data.id);
          localStorage.setItem("token", data.data.token);
        } else {
          alert("登陆失败");
        }
      },
    });
  });
  $(".zhuzhu31").click(function () {
    $.ajax({
      url: "http://jx.xuzhixiang.top/ap/api/login.php",
      type: "get",
      data: { username: $(".zhushou").val(), password: $(".zhuduan").val() },
      success: function (data) {
        if (data.code) {
          window.location.href = "./index.html";
          localStorage.setItem("username", $(".zhushou").val());
          localStorage.setItem("password", $(".zhuduan").val());
          localStorage.setItem("uid", data.data.id);
          localStorage.setItem("token", data.data.token);
        } else {
          alert("登陆失败");
        }
      },
    });
  });
  $("#denglu").click(function () {
    $(".zhubox2").css({ display: "block", "z-index": "9999" });
    console.log(".zhubox2");
    $("#kong").show();
  });
  $("#zhuce").click(function () {
    $("#zhubox").css({ display: "block", "z-index": "9999" });
    $("#kong").show();
  });
  $(".zhubox3 b").click(function () {
    $(".zhubox3").hide();
    $(".zhubox2").hide();
    $("#zhubox").hide();
    $("#kong").hide();
  });
});
